home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir44 / dcg303xa.zip / CASTING.SCR < prev    next >
Text File  |  1993-06-27  |  13KB  |  455 lines

  1. !
  2. ! CASTING.SCR - Spell Casting script
  3. !
  4. ! This script implements spell casting for wizards and elves.
  5. !
  6. ! (c) DC Software, 1992
  7. !
  8. ! Pending Enhancements
  9. !
  10. ! - This script has no voices.  For an example of voices, look at
  11. !   MERCHANT.SCR and HEALER.SCR.  Also, look at the OBJECT.SCR for
  12. !   the sounds that are used for type 1 magic (heal,cure,resurect,
  13. !   etc).  The same kind of sound applies here.
  14. !
  15. ! - This entire set of code is currently duplicated in the OBJECT.SCR
  16. !   file, since type 2 magic can be invoked by both a magic user (casting
  17. !   a spell) or by using an object (Scrolls and Staffs).  I need a 
  18. !   method for writing the script once and including it in two other
  19. !   places.
  20. !
  21.  
  22. :@CAST
  23.  
  24. if player.hp = 0 then 
  25.   writeln( player.name, " is dead!" );
  26.   STOP;
  27. endif;
  28.  
  29. if player.class <> WIZARD and player.class <> ELF then
  30.   writeln( player.name, " does not have magical abilities." );
  31.   STOP;
  32. endif;
  33.  
  34. if player.pwr <= 0 then
  35.   writeln( player.name, " has no power left.." );
  36.   STOP;
  37. endif;
  38.  
  39. if fighting then
  40.   L0 = select( "Kill", 20, "Confuse", 1, "Scare", 2, "Damage", 5, "Paralyze", 5 );
  41.   on L0 goto X_KILL, X_CONFUSE, X_SCARE, X_DAMAGE, X_PARALYZE;
  42. else
  43.   L0 = select( "Destroy",       5,
  44.                "Duplicate",    40,
  45.                "Leave",         5,
  46.                "Resurrect",    50,
  47.                "Inform",        5,
  48.                "Locate Doors", 10,
  49.                "Recharge",     25,
  50.                "Float",        10,
  51.                "Analyze",      10,
  52.                "View",         10 );
  53.   on L0 goto X_DESTROY, X_DUPLICATE, X_LEAVE, X_RESURRECT, X_INFORM,
  54.              X_LOCATE, X_RECHARGE,  X_FLOAT, X_ANALYZE,   X_ZOOM;
  55. endif;
  56.  
  57. writeln( "Ok." );
  58. STOP;
  59.  
  60. :X_DESTROY  
  61.   L0 = DESTROY;   L1 = 5;  L2 = 10;
  62.   gosub X_TARGET; goto X_DOIT;
  63.  
  64. :X_DUPLICATE
  65.   L0 = DUPLICATE; L1 = 40; L2 = 1;
  66.   gosub X_TARGET; goto X_DOIT;
  67.  
  68. :X_LEAVE  
  69.   L0 = LEAVE; L1 = 5;
  70.   goto X_DOIT;
  71.  
  72. :X_RESURRECT
  73.   L0 = RESURRECT; L1 = 50;
  74.   goto X_DOIT;
  75.  
  76. :X_INFORM  
  77.   L0 = INFORM; L1 = 5;
  78.   goto X_DOIT;
  79.  
  80. :X_LOCATE 
  81.   L0 = DOORS; L1 = 10;
  82.   goto X_DOIT;
  83.  
  84. :X_KILL  
  85.   L0 = KILL;    L1 = 20; L2 = 6;
  86.   gosub X_TARGET; goto X_DOIT;
  87.  
  88. :X_CONFUSE  
  89.   L0 = CONFUSE; L1 =  1;
  90.   goto X_DOIT;
  91.  
  92. :X_SCARE  
  93.   L0 = SCARE;   L1 =  2;
  94.   goto X_DOIT;
  95.  
  96. :X_DAMAGE  
  97.   L0 = DAMAGE;  L1 =  5;
  98.   goto X_DOIT;
  99.  
  100. :X_PARALYZE
  101.   L0 = PARALYZE; L1 = 5;
  102.   goto X_DOIT;
  103.  
  104. :X_RECHARGE
  105.   L0 = RECHARGE; L1 = 25; L2 = 1;
  106.   gosub X_TARGET; goto X_DOIT;
  107.  
  108. :X_FLOAT  
  109.   L0 = FLOAT; L1 = 10; L2 = 1;
  110.   gosub X_TARGET; goto X_DOIT;
  111.  
  112. :X_ANALYZE  
  113.   L0 = ANALYZE; L1 = 10; L2 = 1; 
  114.   gosub X_TARGET; goto X_DOIT;
  115.  
  116. :X_ZOOM  
  117.   L0 = ZOOM; L1= 10;
  118.   goto X_DOIT;
  119.  
  120. :X_DOIT
  121.   if player.pwr < L1 then
  122.     writeln( player.name, " doesn't have enough power.." );
  123.     STOP;
  124.   endif;
  125.  
  126.   dec( player.pwr, L1 );
  127.  
  128.   if L0 = DAMAGE or L0 = CONFUSE or L0 = SCARE or L0 = PARALYZE then
  129.     !
  130.     ! These spells operate on EVERY monster
  131.     !
  132.     ! L5 will contain the TOTAL experience points gained when done..
  133.     ! L6 is the maximum damage that will be done to a single monster..
  134.     ! L8 is the maximum total damage that can be done to a group of monsters..
  135.     ! L9 is the number of monsters affected..
  136.     !
  137.     L5 = 0;
  138.     L6 = player.level + adjustments(player.pwr) / 2 + 1;
  139.     if L6 <= 0 then
  140.       writeln( "The spell failed.." );
  141.       STOP;
  142.     endif;
  143.     L8 = player.iq;
  144.     L9 = 0;
  145.   endif;
  146.  
  147.   on L0 goto 
  148.     M2_NONE,     M2_DESTROY,  M2_DUPLICATE, M2_LEAVE,
  149.     M2_RESURRECT,M2_INFORM,   M2_LOCATE,    M2_KILL, 
  150.     M2_CONFUSE,  M2_SCARE,    M2_DAMAGE,    M2_PARALYZE,
  151.     M2_RECHARGE, M2_FLOAT,    M2_ANALYZE,   M2_ZOOM;
  152.  
  153. :M2_NONE      ! No spell
  154.   writeln( "Nothing happens.." );
  155.   STOP;
  156.  
  157. :M2_DESTROY   ! Destroy an object
  158.   writeln( "The ", object.type, " is destroyed.." );
  159.   vanish( object );
  160.   STOP;
  161.  
  162. :M2_DUPLICATE ! Duplicates an object
  163.   writeln( "The ", object.type, " has been duplicated.. " );
  164.   inc( object.count, 1 ); ! Creates an identical copy ! 
  165.   STOP;
  166.  
  167. :M2_LEAVE     ! Exit through the 'exit' door from anywhere...  
  168.   if world.type <> DUNGEON then
  169.     writeln( "This spell only work's in dungeons.." );
  170.     STOP;
  171.   endif;
  172.   enter( world.edgedoor );
  173.   writeln( "You leave this level of the dungeon.." );
  174.   STOP;
  175.  
  176. :M2_RESURRECT ! Revive a DEAD person                   
  177.   write( "Resurrect: " );
  178.   L3 = select( group );
  179.   if player.hp > 0 then
  180.     writeln( player.name, " is not dead!  The spell fails." );
  181.   else
  182.     writeln( player.name );
  183.     player.hp = 2;
  184.     writeln( player.name, " is alive, but weak.." );
  185.   endif;
  186.   STOP;
  187.  
  188. :M2_INFORM    ! Displays some text                     
  189.   loadhint;
  190.   writeln( "The wind seems to carry a random phrase to your ears.." );
  191.   writeln( s0 );
  192.   STOP;
  193.  
  194. :M2_LOCATE    ! Locate doors                           
  195.   for L5 = 0 to 15 do
  196.     if world.doorx(L5) > 0 and world.doory(L5) > 0 then
  197.       frame( world.doorx(L5), world.doory(L5), SYS_FRAME );
  198.     endif;
  199.   endfor;
  200.   STOP;
  201.  
  202. :M2_KILL      ! Kill 1 enemy during battle             
  203.   writeln( npc.name, " killed. +", npc.hp, " exp." );
  204.   inc( player.exp, npc.hp );
  205.   npc.hp = 0;
  206.   STOP;
  207.  
  208. :M2_DAMAGE    ! Causes damage to monsters              
  209.   S0 = "hit";
  210.   foreach npc do
  211.     L7 = min( npc.hp, random(L6) );  ! How much damage to this one monster?
  212.     if L7 > 0 then
  213.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  214.       write( npc.name );
  215.       if L7 < npc.hp then
  216.         write( " hit." );
  217.         dec( npc.hp, L7 );           ! Hit the monster..
  218.       else
  219.         write( " killed!" );
  220.         npc.hp = 0;
  221.       endif;
  222.       writeln( " +", L7, " exp." );
  223.       inc(L9);                       ! Count of affected npcs
  224.       inc( L5, L7 );                 ! Accumulate experience..
  225.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  226.     endif;
  227.   endfor;  
  228.   goto DCSPEXIT;
  229.  
  230. :M2_CONFUSE   ! Makes monsters shoot at other monsters 
  231.   S0 = "confused";
  232.   foreach npc do
  233.     L7 = min( npc.hp, random(L6) );  ! How much confusion to this one monster?
  234.     if L7 > 0 and npc.confused = 0 then
  235.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  236.       inc(L9);                       ! Count of affected npcs
  237.       npc.confused = L7;             ! Confuse for 'n' units
  238.       inc( L5, L7 );                 ! Accumulate experience..
  239.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  240.     endif;
  241.   endfor;  
  242.   goto DCSPEXIT;
  243.  
  244. :M2_SCARE     ! Scares monsters                        
  245.   S0 = "scared";
  246.   foreach npc do
  247.     L7 = min( npc.hp, random(L6) );  ! How much 'fright' to this one monster?
  248.     if L7 > 0 and npc.scared = 0 then
  249.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  250.       inc(L9);
  251.       npc.scared = L7;               ! Frighten for 'n' units
  252.       inc( L5, L7 );                 ! Accumulate experience..
  253.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  254.     endif;
  255.   endfor;  
  256.   goto DCSPEXIT;
  257.  
  258. :M2_PARALYZE  ! Monster can't move                     
  259.   S0 = "paralyzed";
  260.   foreach npc do
  261.     L7 = min( npc.hp, random(L6) );  ! How much paralysis to this one monster?
  262.     if L7 > 0 and npc.paralyzed = 0 then
  263.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  264.       inc(L9);
  265.       npc.paralyzed = L7;            ! Paralyze for 'n' units
  266.       inc( L5, L7 );                 ! Accumulate experience..
  267.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  268.     endif;
  269.   endfor;  
  270.   goto DCSPEXIT;
  271.  
  272. :M2_RECHARGE  ! Recharge an ITEM                       pwr = 25, rng=1
  273.   if object.type = RING or object.type = AMULET or object.type = STAFF then
  274.     inc( object.charges, random(player.level)+1 );
  275.     writeln( "The ", object.type, " now has ", object.charges, " charges." );
  276.   else
  277.     writeln( "The smell of rotten eggs fills the air.." );
  278.   endif;
  279.   STOP;
  280.  
  281. :M2_FLOAT     ! Remove an object's weight              pwr = 10, rng=1
  282.   if object.weight < 255 then
  283.     object.weight = object.weight / 2 + 1;
  284.     writeln( "The ", object.type, " is now much lighter.." );
  285.   else
  286.     writeln( "It's didn't work.  The ", object.type, " is too heavy." );
  287.   endif;
  288.   STOP;
  289.  
  290. :M2_ANALYZE   ! Discover object's properties           pwr = 10, rng=1
  291.   if npc.count then ! It's a character we cast this thing on..
  292.     writeln( npc.name, ", ", npc.class, ", Lvl ", npc.level,
  293.              ", AC ", npc.ac, ", HP ", npc.hp );
  294.   else
  295.     gosub ODETAIL;
  296.   endif;
  297.     STOP;
  298.  
  299. :M2_ZOOM      ! View the world.. 
  300.   viewpcx( world );
  301.   if success then
  302.     pause;
  303.   endif;
  304.   paint( screen );
  305.   STOP;
  306.  
  307.  
  308. !
  309. ! Award experience points (if any)
  310. !
  311. :DCSPEXIT
  312.   if L9 then
  313.     write( L9, " foes were ", S0 );
  314.     if L5 then  
  315.       writeln( " for a total of +", L5, " experience!" );
  316.       inc( player.exp, L5 );           ! Grant experience..
  317.     else
  318.       writeln( " With no effect" );
  319.     endif;
  320.   else
  321.     writeln( "No effect.." );
  322.   endif;
  323.   STOP;
  324.  
  325. !
  326. ! SUBROUTINE: X_TARGET
  327. !
  328. ! Selects a target to cast the spell on
  329. !
  330. :X_TARGET
  331.   write( s0, " what:" );
  332.   L3 = locate;               ! Identify an object or character to cast on !
  333.   if failure then
  334.     writeln( "nothing.." );
  335.     STOP;
  336.   endif;
  337.   if L3 > L2 then
  338.     writeln( "You must get closer.." );
  339.     STOP;
  340.   endif;
  341.   if npc.count then ! It's a character, not an object..
  342.     if npc.type = HOSTILE then
  343.       writeln( npc.name );  ! Monster's class is type of terrain mobility !
  344.     else
  345.       writeln( npc.class ); ! Human, elf, dwarf, etc..       !
  346.     endif;
  347.     if L0 = DESTROY  or L0 = DUPLICATE or
  348.        L0 = RECHARGE or L0 = FLOAT then
  349.       writeln( "This spell only work's on objects!" );
  350.       STOP;
  351.     endif;
  352.   else
  353.     writeln( object.type );  ! Food, weapon, ring, etc..      !
  354.   endif;
  355.   return;
  356.  
  357. !
  358. ! SUBROUTINE: ODETAIL
  359. !
  360. ! Display an object's detailed analysis
  361. !
  362. :ODETAIL
  363.   write( "Name: ", object.name );
  364.   write( ", Type: ", object.type );
  365.   if object.type = FOOD or object.type = POTION  then
  366.     if object.class then
  367.       write( ", Class: ", object.class );
  368.       if object.class <> CURE then
  369.         write( ", Units: ", object.units );
  370.       endif;
  371.     endif;
  372.   elsif object.type = WEAPON then
  373.     write( "Class: ", object.class, 
  374.            ", Hands: ", object.hands, 
  375.            ", Range: ", object.range, 
  376.            ", Damage: ", object.damage );
  377.     if object.ammoneeded then
  378.       write( ", Needs ammo type: ", object.ammo_type );
  379.     endif;
  380.   elsif object.type = AMMO then
  381.     write( "Ammo Type: ", object.ammotype );
  382.     if object.traptype then
  383.       write( ", Poisoned" );
  384.     endif;
  385.     if object.damage then
  386.       write( ", Extra Damage: ", object.damage );
  387.     endif;
  388.   elsif object.type = ARMOR or object.type = SHIELD then
  389.     write( "Armor Class: ", object.ac );
  390.     if object.cursed then
  391.       write( " Cursed!" );
  392.     endif;
  393.   elsif object.type = AMULET or object.type = RING or object.type = GEMS then
  394.     if object.class then
  395.       write( "Class: ", object.class );
  396.       write( ", Charges: ", object.charges );
  397.       if object.class <> CURE then
  398.         write( ", Units: ", object.units );
  399.         if object.permanent then
  400.           write( ", Permanent!" );
  401.         else
  402.           write( ", Temporary" );
  403.         endif;
  404.       endif;
  405.       if object.cursed then
  406.         write( ", Cursed!" );
  407.       endif;
  408.     endif;
  409.   elsif object.type = SCROLL then
  410.     write( "Class: ", object.class );
  411.   elsif object.type = STAFF then
  412.     write( "Class: ", object.class, ", Charges: ", object.charges );
  413.   elsif object.type = CHEST then
  414.     if object.locktype then
  415.       write( "Locked!" );
  416.       if object.traptype = 0 then
  417.         write( ", no traps" );
  418.       elsif object.traptype = 1 then
  419.         write( ", poison trap" );
  420.       else
  421.         write( ", bomb damage: ", object.traptype );
  422.       endif;
  423.     endif;
  424. ! elsif object.type = KEYS     then
  425. !   nothing special about it
  426. ! elsif object.type = BOOK     then
  427. !   nothing special about it
  428. ! elsif object.type = GOLDSACK then
  429. !   nothing special about it
  430. ! elsif object.type = TORCH    then
  431. !   nothing special about it
  432. ! elsif object.type = LANTERN  then
  433. !   nothing special about it
  434. ! elsif object.type = ROPE     then
  435. !   nothing special about it
  436. ! elsif object.type = HOOKS    then
  437. !   nothing special about it
  438. ! elsif object.type = MIRROR   then
  439. !   nothing special about it
  440. ! elsif object.type = SIGN     then
  441. !   nothing special about it
  442.   elsif object.type = VEHICLE then
  443.     write( "Class: ", object.class );
  444. ! else
  445. !   user defined type?
  446.   endif;
  447.   if object.weight > 1 and object.weight < 256 then
  448.     write( ", Weight: ", object.weight );
  449.   endif;
  450.   if object.count > 1 then
  451.     write( ", Count: ", object.count );
  452.   endif;
  453.   return;
  454.  
  455.